|
RAIS
3.2
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.ComponentModel; 00004 using System.Data; 00005 using System.Drawing; 00006 using System.Linq; 00007 using System.Text; 00008 using System.Windows.Forms; 00009 using System.IO; 00010 using System.IO.Compression; 00011 namespace DBPacker 00012 { 00013 public partial class Form1 : Form 00014 { 00015 OpenFileDialog file = new OpenFileDialog(); 00016 public Form1() 00017 { 00018 file.RestoreDirectory = true; 00019 00020 InitializeComponent(); 00021 } 00022 00023 private void button1_Click(object sender, EventArgs e) 00024 { 00025 if (file.ShowDialog() == DialogResult.OK) 00026 { 00027 using (Stream fsSource = file.OpenFile()) 00028 { 00029 byte[] bufferWrite; 00030 00031 FileStream fsDest; 00032 00033 GZipStream gzCompressed; 00034 00035 bufferWrite = new byte[fsSource.Length]; 00036 00037 fsSource.Read(bufferWrite, 0, bufferWrite.Length); 00038 00039 // Open the FileStream to write to 00040 string dir = Directory.GetCurrentDirectory(); 00041 fsDest = new FileStream(dir +"\\RAIS.zip", FileMode.OpenOrCreate, FileAccess.Write); 00042 00043 // Will hold the compressed stream created from the destination stream 00044 00045 gzCompressed = new GZipStream(fsDest, CompressionMode.Compress, true); 00046 00047 // Write the compressed stream from the bytes array to a file 00048 00049 gzCompressed.Write(bufferWrite, 0, bufferWrite.Length); 00050 00051 // Close the streams 00052 00053 fsSource.Close(); 00054 00055 gzCompressed.Close(); 00056 00057 fsDest.Close(); 00058 } 00059 } 00060 this.Close(); 00061 } 00062 } 00063 }